#pragma once

#include "ParseSax.h"
#include "tree.hh"
#include <string>

namespace htmlcxx
{
	namespace HTML
	{
		class ParserDom : public ParserSax
		{
		public:
			ParserDom() {}
			~ParserDom() {}
			const tree<Node> &parseTree(const std::wstring &html);
			const tree<Node> &getTree()
			{
				return mHtmlTree;
			}

		protected:
			virtual void beginParsing();

			virtual void foundTag(Node node, bool isEnd);
			virtual void foundText(Node node);
			virtual void foundComment(Node node);

			virtual void endParsing();

			tree<Node> mHtmlTree;
			tree<Node>::iterator mCurrentState;
		};

		std::wostream &operator<<(std::wostream &stream, const tree<HTML::Node> &tr);
	} //namespace HTML
} //namespace htmlcxx